﻿using System;
using System.Diagnostics;

namespace Mrsoft.Update.Common
{

    /// <summary>
    /// 计时器
    /// </summary>
    public class TimeMeter
    {
        private Stopwatch _sw;

        public void Start() {
            if (_sw == null) {
                _sw = new Stopwatch();
            }
            else {
                _sw.Reset();
            }
            _sw.Start();
        }

        public void Show(string strMsg) {
            _sw.Stop();
            Console.WriteLine("{0}用时:{1}ms", strMsg, (1000 * _sw.ElapsedTicks) / Stopwatch.Frequency);
            _sw.Start();
        }

    }
}
